/*
 * Copyright 2016-2017 TVI Go Easy.
 * Created on 2017/4/24 12:10
 */
package org.mechanic.fund.repository.product;

import org.mechanic.fund.domain.product.Product;
import org.mechanic.fund.domain.product.ProductAttachment;
import org.mechanic.fund.domain.product.ProductAttachmentType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * 产品附件据访问接口
 *
 * @author mechanic
 * @version 0.0.1
 */
public interface ProductAttachmentRepository extends PagingAndSortingRepository<ProductAttachment, String> {
    /**
     * 返回匹配指定产品编号和附件类型编号的按createTime降序排列的产品附件列表
     *
     * @param product 产品
     * @param type 附件类型
     * @return 产品附件列表
     */
    Page<ProductAttachment> findByProductAndProductAttachmentTypeOrderByCreateTimeDesc(
      Product product,
      ProductAttachmentType type, Pageable pageable);
}
